package cn.vshare.service.impl;

import cn.vshare.dao.PermissionSecondDao;
import cn.vshare.entity.PermissionSecond;
import cn.vshare.service.PermissionSecondService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class PermissionSecondServiceImpl implements PermissionSecondService {

    @Resource
    private PermissionSecondDao permissionSecondDao;

    @Override
    public PermissionSecond queryById(String id) {
        return permissionSecondDao.queryById(id);
    }

    @Override
    public List<PermissionSecond> queryByName(String name) {
        return permissionSecondDao.queryByName(name);
    }

    @Override
    public List<PermissionSecond> queryByConditions1(Map<String, Object> map) {
        return permissionSecondDao.queryByConditions(map);
    }

    @Override
    public Page<PermissionSecond> queryByConditions2(Map<String, Object> map) {
        Page page=new Page();
        //使用分页助手,实质是拦截器
        page=PageHelper.startPage((int)map.get("pageNum"),(int)map.get("pageSize"));
        //多条件查询的二级权限信息列表
        List<PermissionSecond> permissionSecondList=permissionSecondDao.queryByConditions(map);
        return page;
    }


    @Override
    public int addPermissionSecond(PermissionSecond permissionSecond) {
        return permissionSecondDao.addPermissionSecond(permissionSecond);
    }

    @Override
    public int updatePermissionSecond(PermissionSecond permissionSecond) {
        return permissionSecondDao.updatePermissionSecond(permissionSecond);
    }

    @Override
    public int deletePermissionSecondById(String id) {
        return permissionSecondDao.deletePermissionSecondById(id);
    }
}
